-
-
Notifications
You must be signed in to change notification settings - Fork 257
feat: support context json schema dump #1296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1296 +/- ##
==========================================
- Coverage 43.46% 43.03% -0.43%
==========================================
Files 22 22
Lines 1972 1992 +20
==========================================
Hits 857 857
- Misses 1115 1135 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, please run the formatter with:
cargo +nightly fmt --all -- --verboseand then run clippy with:
cargo clippy --tests --verbose -- -D warningsto ensure the code passes both checks.
While using schemars to generate JSON Schemas in a code-first manner from the git-cliff-core and git-conventional models isn't necessarily a bad idea, both crates already expose their internal models publicly. Given that, adding schema-generation logic directly into the CLI might slightly drift away from the core purpose of git-cliff, which is primarily a changelog generator.
If you still prefer to support schema generation, you might consider isolating that functionality. For instance, by using remote deriving, you could maintain a small separate project that depends on git-cliff-core and git-conventional, and generate schemas there instead.
This would keep the CLI focused on its main responsibility while still enabling schema generation for external tooling.
|
I have done the Regarding the Schema → SDK issue: I agree this workflow is not ideal in most cases. While Cliff does not define a stable Schema version, every change to Regarding Schema generation, after careful consideration, I approved for defining a separate remote definition for This PR is just a draft idea for now. Maybe a better a approach: We could gate this with a feature flag and, via some process (scripts or an xtask, etc.), generate a Schema when Cliff publishes a release and upload it to the Releases artifacts. Would that be more appropriate? |
|
cc: @orhun Thanks for clarifying. I understand this PR is still a draft. Also, I’m a bit hesitant about this feature itself, as well as adding a related option to the CLI. We should consider whether this functionality is truly needed for most users. Even if it is, it might be cleaner, from a separation-of-concerns perspective, to add a separate binary under
As you also noted, the current implementation direction seems problematic to me as well.
In other words, what's being proposed here effectively shifts the maintenance burden to the maintainers, before we've even established a clear need for the feature. I think we should have a more thorough discussion about the necessity and maintenance cost of this functionality before proceeding further. Personally, I would still recommend creating a separate repository dedicated to schema generation, which could depend on both |
|
Hey, sorry for the delay on this. I'll be having a look soon hopefully |
|
Although I like the changes in this PR, I agree that the output of this CLI command would be too specific to the current release of I'm not sure how a separate repo would look like for this. Are there any example projects that do that we could get inspired from? Thoughts? |
|
I don't know of any open-source projects that apply an implementation or operational approach like the one presented in this PR, but I believe there are internal tools that use JSON Schema to validate data type consistency. I could try generating the schema using |
|
Yeah, I think that's a fair approach. Thanks for looking into this! |
|
By the way, I've re-read the related issue: and I’m wondering — is From my understanding, it doesn't seem like the issue's context involves using |
The limited for For example, if you’re using third-party planning/project-management tools like Linear or Feishu and need to map your journal content (preferably only PRs) to task id and titles in those tools, then using Sry, the generator is internal tool, I cannot share it public.
Yes, I agree with this approach as well. This PR is mainly a prototype for the workflow described above. Publishing it in a separate repository, or bundling it with a Release artifact, would both be good options. External users could use this file to directly generate the
Yes. Cliff is an actively evolving project, and the Context may change quite frequently. There’s no plan to provide stable type guarantees, and introducing a VERSION field to mark versions would be cumbersome. So treating this as something (a) exposed only behind a feature flag, (b) published alongside each release, or (c) maintained as a per-version schema in the repository are all acceptable trade-offs. Asking users to define their own interfaces to adapt to the Context is too cumbersome and hard to validate—if the type definitions change substantially, it’s difficult for type checkers like |
|
Thanks for the clarification @greenhat616 . I still haven't fully grasped in your use case which specific field(s) of
I'm not familiar with Linear myself, but according to their docs, if you include the Linear issue ID in the PR title, Linear automatically links the PR to the issue. If that's the case, wouldn't it be possible to use this feature: in Also, regarding schema validation: typically, schema or type validation is used at untrusted data boundaries. I'm not sure if If only certain fields of the context are problematic, it might be simpler to just treat the context as plain JSON and access or update the relevant fields via their paths — without deserializing the entire structure into a strict data model. After all, That said, it might be a good idea to first make sure this PR passes the tests and that the JSON Schema is properly generated. At the moment, it's hard to verify anything without that. |
Description
Close #1294. Add JSON Schema dump feature.
Current blocked by crate-ci/git-conventional#88.
Motivation and Context
Add a gloabl opt
--dump-context-schemato dump current versionContextJSON Schema.How Has This Been Tested?
Screenshots / Logs (if applicable)
Types of Changes
Checklist: